package com.heima.wemedia.controller.v1;

import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    private WmChannelService wmChannelService;

    /**
     * 频道列表查询
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult  findAll(){
        return wmChannelService.findAll();
    }

    /**
     * 新增频道
     * @param adChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannel adChannel){
        return wmChannelService.saveChannel(adChannel);
    }

    /**
     * 频道列表分页查询
     * @param channelDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto channelDto){
        return wmChannelService.list(channelDto);
    }

    /**
     * 删除频道
     * @param id
     * @return
     */
    @GetMapping("del/{id}")
    public ResponseResult del(@PathVariable("id") Integer id){
        return wmChannelService.del(id);
    }

    /**
     * 更新频道
     * @param adChannel
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){

        return wmChannelService.update(adChannel);
    }
}
